package org.dallasrowing.logbook.ui.controller;

import java.util.List;

import org.dallasrowing.logbook.ui.view.BeanEditorWidget;
import org.dallasrowing.model.Rower;
import org.dallasrowing.model.dao.DAOException;
import org.dallasrowing.model.dao.RowersDAO;

public class RowerBeanEditorControllerImpl extends BeanEditorControllerImpl<Rower> {

	private RowersDAO rowersDao;

	public RowerBeanEditorControllerImpl(
			AdminWindowController parentController, BeanEditorWidget<Rower> widget, RowersDAO rowersDAO) {
		super(parentController, widget);
		this.rowersDao = rowersDAO;
		init();
	}

	@Override
	protected void updateBean(Rower bean) throws DAOException {
		rowersDao.updateRower(bean);
	}

	@Override
	protected void createBean(Rower bean) throws DAOException {
		rowersDao.createNewRower(bean);
	}

	@Override
	protected List<Rower> getAllBeans() throws DAOException {
		return rowersDao.searchRowersByName("", false);
	}

	@Override
	protected Rower newBean() throws DAOException {
		return new Rower();
	}

}